<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class MY_Upload extends CI_Upload
{
	function ajax_do_upload($field='userfile') {
		$this->do_upload($field);
		$fileuploaded_info = $this->data();
		
		$error = $this->display_errors('','');
		$msg = $_FILES[$field]['name'] . ", File Size: " . @filesize($_FILES[$field]['tmp_name']);
		$msg2 = $fileuploaded_info['file_name']; 
		
		//--for security reason, we force to remove all uploaded file
		@unlink($_FILES[$field]);		
				
		$output = "{";
		$output .= "error: '" . $error . "',\n";
		$output .= "msg: '" . $msg . "',\n";
		$output .= "msg2: '" . $msg2 . "'\n";
		$output .= "}";
		
		return $output;
	}
}
